<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageDataViews.aspx.cs" Inherits="WIntegrator.Pages.ManageDataViews" %>

<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Manage Data Views</title>
</head>
<body>
    <form id="form1" runat="server">
            <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>    
    <div>
<table width="515" border="0" cellpadding="0" cellspacing="1px">
  <tr>
    <td width="79">&nbsp;</td>
    <td width="116">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
    <td colspan="2" rowspan="7" valign="middle" align="center">To create a new Data View you must select a valid location and department. </td>
  </tr>
  <tr>
    <td colspan="2" align="right">Select  Location: </td>
    <td colspan="2">
        <telerik:RadComboBox ID="ddProductionLocation" runat="server" 
                             AutoPostBack="true" 
                             DataSourceID="SqlDataSource_ProductionLocation"
                             DataTextField="LocationName"
                             DataValueField="ProductionLocationID"
                             Skin="Telerik"
                             OnSelectedIndexChanged="ddProductionLocation_SelectedIndexChanged"
                             AppendDataBoundItems="true">
                             <Items>
                                <telerik:RadComboBoxItem Selected="true" Text="Select one" Value="-1" />
                             </Items>
        </telerik:RadComboBox>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right">Select Department: </td>
    <td colspan="2">
        <telerik:RadComboBox ID="ddCompanyDepartments" runat="server" 
                             DataSourceID="SqlDataSource_CompanyDepartments"
                             DataTextField="DepartmentName"
                             DataValueField="CompanyDepartmentID"
                             Skin="Telerik"
                             AutoPostBack="true"
                             AppendDataBoundItems="true" >
                             <Items>
                                <telerik:RadComboBoxItem Text="Select one" Value="-1" />
                             </Items>
        </telerik:RadComboBox>
    </td>
  </tr>
    <tr>
        <td>&nbsp;</td>
        <td align="right">Select Status:</td>
        <td colspan="2">
            <telerik:RadComboBox ID="ddStatus" runat="server"
                                 DataSourceID="SqlDataSource_Status"
                                 DataTextField="Description" 
                                 DataValueField="Code"
                                 AppendDataBoundItems="true" 
                                 Skin="Telerik">
                                 <Items>
                                    <telerik:RadComboBoxItem Text="Select one" Value="-1" Selected="true" />
                                 </Items>
            </telerik:RadComboBox>
        </td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right">Name:</td>
    <td colspan="2">
        <telerik:RadTextBox ID="txtName" Skin="Telerik" runat="server"> </telerik:RadTextBox>
    </td>
  </tr>
  <tr>
    <td align="right" colspan="2">&nbsp;Show red flagged orders only:</td>
    <td colspan="2">
        <asp:CheckBox ID="isRedFlag" runat="server" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td width="91" align="center">
        <asp:Button ID="Save" runat="server" Text="Save" CssClass="Grid" OnClick="Save_Click"/></td>
    <td width="85" align="center">
        <input id="Reset1" type="reset" value="Cancel" class="Grid"/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td colspan="2" valign="middle" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="6" class="ColumnsHeaders">My Data Views </td>
  </tr>
    <tr>
        <td class="ColumnsHeaders" colspan="6">
            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AutoGenerateDeleteColumn="True" DataSourceID="ObjectDataSource_DataViews" GridLines="None"
                ShowGroupPanel="True" Skin="Telerik">
                <ExportSettings>
                <Pdf PaperSize="Letter" FontType="Subset"></Pdf>

                <Excel Format="Html"></Excel>
                </ExportSettings>

                <MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" DataSourceID="ObjectDataSource_DataViews" Dir="LTR" Frame="Border" TableLayout="Auto" CommandItemDisplay="None">
                <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False">
                <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>

                <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False" Resizable="False">
                <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>

                <EditFormSettings>
                <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></EditColumn>
                </EditFormSettings>
                
                <Columns>
                    <telerik:GridBoundColumn DataField="DataViewType" HeaderText="Department" ReadOnly="True" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None" UniqueName="DataViewType"/>
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Data View Name" ReadOnly="True" Groupable="False" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None" UniqueName="Description" />
                </Columns>
                </MasterTableView>

                <ClientSettings AllowDragToGroup="True"></ClientSettings>
            </telerik:RadGrid>
        </td>
    </tr>

  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td colspan="2" valign="middle" align="center">&nbsp;</td>
  </tr>
</table>
    <asp:SqlDataSource ID="SqlDataSource_ProductionLocation" runat="server" ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>"
        SelectCommand="SELECT [ProductionLocationID], [LocationName] FROM [Production_Locations] order by LocationName" >
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSource_CompanyDepartments" 
         runat="server" 
         ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>">

    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource_Status" 
                       runat="server" 
                       ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>" SelectCommand="Status_GetAll" SelectCommandType="StoredProcedure">
       
    </asp:SqlDataSource>
    
<!-- Grid Object data source ---->
    <asp:ObjectDataSource ID="ObjectDataSource_DataViews" runat="server" OldValuesParameterFormatString="{0}" SelectMethod="GetAll" TypeName="Xeneize.SolaraBL.SolaraDataViews" DeleteMethod="Delete">
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="UserID" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="DataViewID" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>    
    </div>
    </form>
</body>
</html>
